<template>
  <div>
    <Header title="地址列表" />
    <van-address-list
      v-model="store.chosenAddressId"
      :list="store.addressList"
      default-tag-text="默认"
      @add="onAdd"
      @edit="onEdit" />
  </div>
</template>

<script setup>
  import Header from "@/components/Header.vue"
  import { onMounted } from "vue"
  import { useRouter } from "vue-router"
  import useAddressStore from "@/store/addressStore"
  const store = useAddressStore()
  const router = useRouter()
  onMounted(() => {
    //初始化地址列表
    store.asyncGetAddressList()
  })

  const onAdd = () => router.push("/addressManage")
  const onEdit = item => {
    router.push("/addressManage?addressId=" + item.id)
  }
</script>

<style scoped lang="less"></style>
